function getMaxSubSum(arr) {
    let flag = false;
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] > 0) {flag = true; break;}
    }
    if (!flag) {
        return 0;
    }
    let max_sum = 0;
    for (let i = 0; i < arr.length; i++) {
        let cur_sum = 0;
        for (let j = i; j < arr.length; j++) {
            cur_sum += arr[j];
            if (cur_sum > max_sum) {
                max_sum = cur_sum;
            }
        }
    }
    return max_sum;
}


alert(getMaxSubSum([-1,2,3,-9]));

alert(getMaxSubSum([2,-1,2,3,-9]));

alert(getMaxSubSum([-1,2,3,-9,11]));

alert(getMaxSubSum([-2,-1,1,2]));

alert(getMaxSubSum([100,-9,2,-3,5]));

alert(getMaxSubSum([1,2,3]));
